package WaiBao;

import java.util.Arrays;

public class LiFang {
    public static void main(String[] args) {
        String[] name = {"李丽火(班长)", "金家荣(副班长)", "小李(学习委员)", "王俊明(团支书)", "黄文王", "张医护", "高于量", "杨培芳", "凌颖慧", "王怡乐", "潘继伟", "郑诗雨",
                "沈丽君", "王挨", "李世杰", "黄熊安", "苏紫婷", "林培育", "周润发", "张义虎", "程淑仪", "潘金伟", "杨亚萍", "黄唯一", "程建豪", "王才配", "邓海", "张俊丽",
                "刘亦菲", "李芳(学生)"};//考生本人:李芳(学生)
        int[] age = {19,20, 20, 18, 20,21, 23, 18, 19, 19, 18, 19, 18, 22, 21, 19, 18, 19, 18, 20, 19, 19, 20, 20, 20, 18, 20, 19, 18, 20};//考试年龄：20

        double[] maple1 = {89, 78, 59, 86, 79, 68, 78, 99, 60, 80, 90, 87, 85, 79, 65, 68, 69, 99, 96, 88, 92, 91, 95, 85, 75, 74, 74, 84, 89, 96};
        double[] maple2 = {65, 71, 87, 83, 61, 86, 78, 83, 60, 90, 90, 67, 86, 75, 65, 65, 86, 79, 66, 78, 82, 71, 85, 85, 75, 89, 74, 79, 84, 96};
        double[] maple3 = {77, 85, 69, 74, 81, 65, 67, 69, 80, 60, 93, 87, 85, 85, 65, 98, 89, 79, 96, 63, 92, 81, 95, 85, 76, 88, 73, 78, 78, 95};


        double spruce;//代表每个学生的总分
        double locust;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            spruce =  maple1[i] +  maple2[i] + maple3[i];
//            locust = (spruce * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" +spruce);
//            System.out.println(name[i] + "的平均分为:" + locust);
//        }


        double sum2 = 0;
//        for (int i = 0; i < maple1.length; i++) {
//            sum2+=maple1[i];
//        }
//        rowan1 = (sum2*1.0)/30;
//        System.out.println("分析化学的班级平均分为:"+ rowan1);
//        double Sum = 0;
//        for (int i = 0; i < maple2.length; i++) {
//            Sum+=maple1[i];
//        }
//        rowan2 = (Sum*1.0)/30;
//        System.out.println("线性代数的班级平均分为:"+rowan2);
//        double sum = 0;
//        for (int i = 0; i <maple3.length; i++) {
//            sum+=maple1[i];
//        }
//        rowan3 = (sum*1.0)/30;
//        System.out.println("有机化学的班级平均分为:"+ rowan3);


        double rowan1 = 0,rowan2 = 0, rowan3 = 0;//计算每门课的平均分
        double teak1 = 0,teak2 = 0,teak3 = 0;//计算每门课标准差
        double beech1 = 0, beech2 = 0,beech3 = 0;//计算每门课中位数
        for (int i = 0; i < maple1.length; i++) {
            sum2+=maple1[i];
        }
        rowan1 = (sum2*1.0)/30;
        System.out.println("分析化学的班级平均分为:"+ rowan1);
        double Sum = 0;
        for (int i = 0; i < maple2.length; i++) {
            Sum+=maple2[i];
        }
        rowan2 = (Sum*1.0)/30;
        System.out.println("线性代数的班级平均分为:"+ rowan2);
        double sum = 0;
        for (int i = 0; i <maple3.length; i++) {
            sum+=maple3[i];
        }
        rowan3 = (sum*1.0)/30;
        System.out.println("有机化学的班级平均分为:"+ rowan3);




        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i < maple1.length; i++) {
            c1+= (maple1[i] - rowan1)*(maple1[i] -  rowan1);
        }
        teak1 = Math.sqrt(c1*1.0/30);
        System.out.println("分析化学的班级标准差为:"+ teak1);

        for (int i = 0; i <maple2.length; i++) {
            c2+= (maple2[i] - rowan2)*(maple2[i] - rowan2);
        }
        teak2 = Math.sqrt(c2*1.0/30);
        System.out.println("线性代数的班级标准差为:"+ teak2);

        for (int i = 0; i <maple3.length; i++) {
            c3+= (maple3[i] -  rowan3)*(maple3[i] - rowan3);
        }
        teak3 = Math.sqrt(c3*1.0/30);
        System.out.println("有机化学的班级标准差为:"+teak3);
//
//
//
//        Arrays.sort(maple1);
//        Arrays.sort(maple2);
//        Arrays.sort(maple3);
//        beech1 =( maple1[14]+maple1[15])*1.0/2;
//        beech2 =( maple2[14]+maple2[15])*1.0/2;
//        beech3 =( maple3[14]+maple3[15])*1.0/2;
//        System.out.println("分析化学的中位数为:"+ beech1);
//        System.out.println("线性代数的中位数为:"+ beech2);
//        System.out.println("有机化学学的中位数为:"+ beech3);
    }
}
